package com.badlogic.androidgames.game;
import android.graphics.Color;
import android.util.Log;

import com.badlogic.androidgames.framework.Game;
import com.badlogic.androidgames.framework.Graphics;
import com.badlogic.androidgames.framework.Screen;

public class Level01 extends Screen {

	Player player;
	Enemy enemy1;
	
	public Level01(Game game) {
		super(game);		
		Load();
	}
	
	public void Load()
	{
		
		
		StaticObjects.walls = new Wall[]
		{
			//new Wall(Assets.Wall,new Vector2(0,0),new Vector2(100,100)),
				
			new Wall(Assets.Wall,new Vector2(0,320 - 30),new Vector2(480,30)),
			//caixas
			new Wall(Assets.Wall,new Vector2(0,211),new Vector2(70,80)),
			new Wall(Assets.Wall,new Vector2(480 - 70,211),new Vector2(70,80)),
			//bastoes 
			new Wall(Assets.Wall,new Vector2(0,212 - 70),new Vector2(20,70)),
			new Wall(Assets.Wall,new Vector2(480 - 20,212 - 70),new Vector2(20,70)),
						
			new Wall(Assets.Wall,new Vector2(0,213 - 80),new Vector2(150,10)),
			new Wall(Assets.Wall,new Vector2(480 - 150,213 - 80),new Vector2(150,10)),
			
			new Wall(Assets.Wall,new Vector2(480/2 - 70/2,212 - 80),new Vector2(70,10)),
			
			new Wall(Assets.Wall,new Vector2(0,50),new Vector2(480,10))	
			
		};
		
		StaticObjects.doors = new Door[]
		{
			new Door(Assets.Door,new Vector2(40,210 - 80 - 60),new Vector2(10,60)),
			new Door(Assets.Door,new Vector2(480 - 40 - 10,210 - 80 - 60),new Vector2(10,60))
		};
		
		player = new Player(Assets.PlayerWalkD, new Vector2(300, 200), new Vector2(35, 35), new Vector2(19, 22));
		enemy1 = new Enemy(Assets.CaveiraD, new Vector2(200,268),new Vector2(24,24),
							new Vector2(12,12),2f, new Vector2(110,330), Assets.CaveiraE);
		TouchManager.getInstance();
	}

	@Override
	public void update(float deltaTime) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void present(float deltaTime) {
		Graphics g = game.getGraphics();
		
		g.clear(Color.BLACK);
		
		if(StaticObjects.walls != null)
		{
			for(int i = 0; i < StaticObjects.walls.length; i++)
			{
				StaticObjects.walls[i].Draw(g, Color.BLUE);
			}
		}
		
		if(StaticObjects.doors != null)
		{
			for(int i = 0; i < StaticObjects.doors.length; i++)
			{
				StaticObjects.doors[i].Draw(g);
			}
		}
		
		enemy1.Draw(g);
		
		if(TouchManager.getInstance().FirstTouch(TouchManager.NAME_BUTTON.CIMA))
		{
			Log.e("TesteInput", "FIRST_TOUCH");
		}
		if(TouchManager.getInstance().NotTouch(TouchManager.NAME_BUTTON.CIMA))
		{
			Log.e("TesteInput", "NOT_TOUCH");
		}
		if(TouchManager.getInstance().ContinuousTouch(TouchManager.NAME_BUTTON.CIMA))
		{
			Log.e("TesteInput", "CONTINUOUS_TOUCH");
		}
		if(TouchManager.getInstance().UpTouch(TouchManager.NAME_BUTTON.CIMA))
		{
			Log.e("TesteInput", "UP_TOUCH!");
		}
		
		
		player.Update(game, deltaTime);
		enemy1.Update(deltaTime);
		player.Draw(g);
		TouchManager.getInstance().Update(game);
		TouchManager.getInstance().DrawObject(g, TouchManager.NAME_BUTTON.CIMA);
	}

	@Override
	public void pause() {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void resume() {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void dispose() {
		// TODO Auto-generated method stub
		
	}

}
